<template>
  <el-row v-loading="loading">
    <p>通道状态：<span class="fz12" :class="chennel_status === -200 ? 'err' : chennel_status === 200 ? 'succ' : 'tip'">{{ chennel_status === -200 ? '审核未通过' : chennel_status === 0 ? '未提交' : chennel_status ===  100 ? '待审核' : chennel_status === 200 ? '审核通过': '无' }}</span></p>
    <p v-if="chennel_status === -200">错误信息：<span class="fz12 err">{{ error_info }}</span></p>
    <p>支付宝账号：{{ ali.ali_count }}</p>
    <p>支付宝授权PID：{{ ali.ali_pid }}</p>
    <p>商家结算周期：{{ ali.balance_type }}</p>
    <p>通道类型：{{ ali.channel_type === 0 ? '普通' : ali.channel_type === 1 ? '蓝海行动' : ali.channel_type === 2 ? '公益类': '无' }}</p>
    <p>当前执行费率：{{ ali.rate }}%</p>
    <p v-if="ali.channel_type !== 2">到期时间：{{ ali.expire_time }}</p>
    <p v-if="ali.expire_time">到期执行费率：{{ ali.expire_rate }}%</p>
  </el-row>
</template>

<script>
import { merchantChannelAliQuery } from '@/api/shop'

export default {
  data() {
    return {
      loading: true,
      chennel_status: '',
      error_info: '',
      ali: {
        ali_pid: '',
        ali_count: '',
        balance_type: '',
        rate: '',
        expire_time: '',
        expire_rate: '',
        channel_type: null
      }
    }
  },
  methods: {
    handleDocumentInit() {
      merchantChannelAliQuery(this.$route.query.merchant_num).then(res => {
        if (res.data.errorCode === 0) {
          this.loading = false
          this.ali.ali_count = res.data.result.ali_count
          this.ali.ali_pid = res.data.result.ali_pid
          this.ali.balance_type = res.data.result.balance_type
          this.ali.channel_type = res.data.result.channel_type
          this.ali.expire_rate = Number(res.data.result.expire_rate)
          this.ali.expire_time = res.data.result.expire_time
          this.ali.rate = Number(res.data.result.rate)
          this.chennel_status = res.data.result.channel_status
          this.error_info = res.data.result.error_info
        } else {
          this.$message.error(res.data.errorMsg)
        }
      })
    }
  },
  created() {
    this.handleDocumentInit()
  }
}
</script>
